package com.tsunami.log.event;

import com.tsunami.log.entity.OptLogDTO;
import lombok.AllArgsConstructor;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.Async;

import java.util.function.Consumer;

/**
 * @Classname SysLogListener
 * @Description TODO
 * @Date 2021-09-18 16:46
 * @Created by lx
 */
@AllArgsConstructor
public class SysLogListener {

    private Consumer<OptLogDTO> consumer;

    @Async
    @Order
    @EventListener(SysLogEvent.class)
    public void saveSysLog(SysLogEvent event){
        OptLogDTO optLogDTO = (OptLogDTO) event.getSource();

        consumer.accept(optLogDTO);
    }
}
